﻿@model List<Faurecia.WM.Service.Dtos.ProductPropertyDictionaryDto>
<div class="page-bar">
    <ul class="page-breadcrumb">
        <li>
            <span id="module">佛吉亚管理</span>
            <i class="fa fa-angle-right"></i>
        </li>
        <li>
            <span id="action">推车列表</span>
        </li>
    </ul>
</div>
<!-- END PAGE BAR -->
<div class="mt-bootstrap-tables" style="margin-top: 20px">
    <div class="row">
        <div class="col-md-12">
            <div class="portlet light bordered">
                <div class="portlet-title">
                    <div class="caption">
                        <i class="icon-social-dribbble font-green hide"></i>
                    </div>
                    <div class="actions">
                        <a class="btn btn-default" href="@Url.Action("Edit")">
                            <i class="fa fa-plus"></i>创建
                        </a>
                    </div>
                </div>
                <div class="portlet-body">
                    <table id="table-pagination" data-toggle="table" data-url="@Url.Action("GetPagedList", new {ViewBag.ProductTypeId })"
                           data-height="526"
                           data-form-id="defaultForm"
                           data-show-refresh="true"
                           data-page-size="10"
                           data-page-list="[5, 10, 20, 50, 100, 200]"
                           data-search="true">
                        <thead>
                        <tr>
                            <th data-formatter="RowNumber" data-width="50">序号</th>
                            @if (Model != null && Model.Count > 0)
                            {
                                foreach (var productType in Model)
                                {
                                    <th data-field=@("PropertyDictionary." + productType.KeyId)>@(productType.Key)</th>
                                }
                            }
                            <th data-align="right" data-field="ProductMinimumCount" data-width="100">预警数</th>
                            <th data-align="center" data-field="CreatedTime" data-width="200">创建时间</th>
                            <th data-align="center" data-formatter="opColumns" data-width="220">操作</th>
                        </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

@section scripts{
    <script type="text/javascript">

        var opColumns = function (value, row, index) {
            return `<a href="/Product/Edit/_id_">修改</a>
                      | <a href="javascript:remove('_id_');">删除</a>`
                .replace(/_id_/ig, row.Id).replace(/_row_/ig, escape(JSON.stringify(row)));
        },
            remove = function (id) {
                bootbox.confirm('是否确认删除？', function (result) {
                    if (!result) {
                        return;
                    }
                    $.ajax({
                        type: 'POST',
                        url: '@Url.Action("Delete")',
                        data: { Id: id },
                        async: false,
                        success: function (result) {
                            if (result.Success) {
                                $('#table-pagination').bootstrapTable('refresh');
                            } else {
                                showToast(3, '系统消息', result.Message);
                            }
                        }
                    });
                });
            };
    </script>
}
